import java.util.Random;

class Action
{
	private boolean bAvailable; // for dailies, etc...
	private int iMin;
	private int iMax;
	private int iAttacks; // 0 = AC, 1=Ref, 2=Wil, 3 =Fort
	private int iBonus;
	private Random rGenerator;
	Action()
	{
		bAvailable = true;
		iMin = 1;
		iMax = 1;
		iAttacks = 0;
		iBonus = 2;
		rGenerator = new Random();
	}
	Action(int iMyMin, int iMyMax, int iMyAttacks, int iMyBonus)
	{
		bAvailable = true;
		iMin = iMyMin;
		iMax = iMyMax;
		iAttacks = iMyAttacks;
		iBonus = iMyBonus;
		rGenerator = new Random();
	}
	public void SetMin(int iMyMin)
	{
		iMin = iMyMin;
	}
	public void SetMax(int iMyMax)
	{
		iMax = iMyMax;
	}
	public void SetAttacks(int iMyAttacks)
	{
		iAttacks = iMyAttacks;
	}
	public void SetBonus(int iMyBonus)
	{
		iBonus = iMyBonus;
	}
	public void DoAction(Combatant Target)
	{
		int iTargetNum = 0;
		switch(iAttacks)
		{
			case 0: iTargetNum = Target.GetAC(); break;
			case 1: iTargetNum = Target.GetReflex(); break;
			case 2: iTargetNum = Target.GetWill(); break;
			case 3: iTargetNum = Target.GetFort(); break;
		}				
		
		int iRoll = rGenerator.nextInt(20);
		iRoll++; //1-20
		iRoll += iBonus;
		
		if(iRoll >= iTargetNum)
		{
			int iMyDamage = rGenerator.nextInt(iMax-iMin);
			iMyDamage += iMin + 1;
			Target.TakeDamage(iMyDamage);
		}
		else
		{
			System.out.println(Target.GetName() + " is missed!");
		}
	}
}
